﻿<%@ Page Language="C#" MasterPageFile="~/Hoso/MasterPage_Hoso.master" AutoEventWireup="true" CodeFile="QuanlyChuyenmuc.aspx.cs" Inherits="Hoso_QuanlyChuyenmuc" %>
<%@ Register TagPrefix="uc" TagName="Menu" Src="~/Hoso/QuantriMenu.ascx"%>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <uc:Menu ID="menu" runat="server" />
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
       
       <!-- load ajax-->
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <!-- end-->
   
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="650px"
        AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" 
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True"
        DataSourceID="SqlDataSource1" GridLines="None" 
        ondatabound="RadGrid1_DataBound" onitemdeleted="RadGrid1_ItemDeleted" 
        oniteminserted="RadGrid1_ItemInserted" 
        onitemupdated="RadGrid1_ItemUpdated" Skin="Office2007" 
        onitemcommand="RadGrid1_ItemCommand" PageSize="5" >
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

<MasterTableView AutoGenerateColumns="False" DataKeyNames="machuyenmuc" 
            DataSourceID="SqlDataSource1" CommandItemDisplay="Top">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
    
     <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColum" FilterControlAltText="Filter EditCommandColumn column">
                    </telerik:GridEditCommandColumn>
                    
        <telerik:GridBoundColumn DataField="machuyenmuc" DataType="System.Int32" 
            FilterControlAltText="Filter machuyenmuc column" HeaderText="Mã chuyên mục" 
            ReadOnly="True" SortExpression="machuyenmuc" UniqueName="machuyenmuc">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="tenchuyenmuc" 
            FilterControlAltText="Filter tenchuyenmuc column" HeaderText="Tên chuyên mục" 
            SortExpression="tenchuyenmuc" UniqueName="tenchuyenmuc">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="mota" 
            FilterControlAltText="Filter mota column" HeaderText="Mô tả chuyên mục" 
            SortExpression="mota" UniqueName="mota">
        </telerik:GridBoundColumn>
         <telerik:GridDropDownColumn DataField="matinhtrangcm" DataType="System.Int32"  
            ListTextField="tentinhtrangcm" ListValueField="matinhtrangcm"
         ColumnEditorID="GridDropDownColumnEditor1"  DataSourceID="SqlDataSource2"
            FilterControlAltText="Filter matinhtrangcm column" HeaderText="Tên tình trạng" 
            SortExpression="matinhtrangcm" UniqueName="matinhtrangcm">
         </telerik:GridDropDownColumn>
          <telerik:GridButtonColumn ConfirmText="Delete chuyên mục ?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                    </telerik:GridButtonColumn>
    </Columns>

<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 <ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="True" />
               <ClientEvents OnRowDblClick="RowDblClick" />
           </ClientSettings>
<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>     
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        DeleteCommand="DELETE FROM [CHUYENMUC] WHERE [machuyenmuc] = @original_machuyenmuc" 
        InsertCommand="INSERT INTO [CHUYENMUC] ([tenchuyenmuc], [mota], [matinhtrangcm]) VALUES (@tenchuyenmuc, @mota, @matinhtrangcm)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT * FROM [CHUYENMUC]" 
        UpdateCommand="UPDATE [CHUYENMUC] SET [tenchuyenmuc] = @tenchuyenmuc, [mota] = @mota, [matinhtrangcm] = @matinhtrangcm WHERE [machuyenmuc] = @original_machuyenmuc">
        <DeleteParameters>
            <asp:Parameter Name="original_machuyenmuc" Type="Int32" />
            <asp:Parameter Name="original_tenchuyenmuc" Type="String" />
            <asp:Parameter Name="original_mota" Type="String" />
            <asp:Parameter Name="original_matinhtrangcm" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="tenchuyenmuc" Type="String" />
            <asp:Parameter Name="mota" Type="String" />
            <asp:Parameter Name="matinhtrangcm" Type="Int32" />
            <asp:Parameter Name="original_machuyenmuc" Type="Int32" />
            <asp:Parameter Name="original_tenchuyenmuc" Type="String" />
            <asp:Parameter Name="original_mota" Type="String" />
            <asp:Parameter Name="original_matinhtrangcm" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="tenchuyenmuc" Type="String" />
            <asp:Parameter Name="mota" Type="String" />
            <asp:Parameter Name="matinhtrangcm" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        SelectCommand="SELECT [matinhtrangcm], [tentinhtrangcm] FROM [TINHTRANGCM]">
    </asp:SqlDataSource>
</asp:Content>
